*Figure 3

************************************************************************************************
********************************Distribution of Standard Deviation by Question****************************************
************************************************************************************************

use "Data_ImportantProvisions_240423.dta", clear


egen agreement_general = rowsd(general_*_num)
egen agreement_func_democ = rowsd(func_democ_*_num)
egen agreement_new_democ = rowsd(new_democ_*_num)
egen agreement_divided_democ = rowsd(divided_democ_*_num)


*A) Countries in General
hist agreement_general, fraction title("") xtitle("Standard Deviation") title("") color(r) xlabel(0.5(0.2)1.7) 
forval i=1/9{
      gr_edit .plotregion1.plot1.EditCustomStyle , j(`i') style(area(shadestyle(color(maroon%70))))
}
forval i=10/20{
      gr_edit .plotregion1.plot1.EditCustomStyle , j(`i') style(area(shadestyle(color(maroon))))
}
graph export "Figure_3_A.pdf", replace
graph save sd_distribution_general.gph, replace


*B) Functioning Democracies
hist agreement_func_democ, fraction  xlabel(0.5(0.2)1.7) xtitle("Standard Deviation") title("") color(r) 
forval i=1/9{
      gr_edit .plotregion1.plot1.EditCustomStyle , j(`i') style(area(shadestyle(color(navy%70))))
}
forval i=10/20{
      gr_edit .plotregion1.plot1.EditCustomStyle , j(`i') style(area(shadestyle(color(navy))))
}
graph export "Figure_3_B.pdf", replace
graph save sd_distribution_func_democ.gph, replace

*C) New Democracies
hist agreement_new_democ, fraction xtitle("") xlabel(0.5(0.2)1.7) xtitle("Standard Deviation") title("") color(r) 
forval i=1/9{
      gr_edit .plotregion1.plot1.EditCustomStyle , j(`i') style(area(shadestyle(color(forest_green%70))))
}
forval i=10/20{
      gr_edit .plotregion1.plot1.EditCustomStyle , j(`i') style(area(shadestyle(color(forest_green))))
}
graph export "Figure_3_C.pdf", replace
graph save sd_distribution_new_democ.gph, replace

*D) Divided Democracies
hist agreement_divided_democ, fraction  xlabel(0.5(0.2)1.7)  xtitle("Standard Deviation") title("") color(r) 
forval i=1/9{
      gr_edit .plotregion1.plot1.EditCustomStyle , j(`i') style(area(shadestyle(color(purple%70))))
}
forval i=10/20{
      gr_edit .plotregion1.plot1.EditCustomStyle , j(`i') style(area(shadestyle(color(purple))))
}
graph save sd_distribution_divided_democ.gph, replace
graph export "Figure_3_D.pdf", replace


erase sd_distribution_func_democ.gph 
erase sd_distribution_new_democ.gph 
erase sd_distribution_divided_democ.gph
erase sd_distribution_general.gph
